<?php
/*
Description:
Rate related functions.

Function List:
1	select_rate($title,$user,$rate)
	

*/

//1------------------------------------------------------------------------------------------------1
function select_rate($title,$user,$rate)
{
	include("Libraries/Dal/DB_Queries.php");
	include("Libraries/User_Input_Validation.php");
	
	//voted again or not
	$game_id=get_game_id($title);
	$member_id=get_member_id($user);
	
	//$member_id = mysql_real_escape_string($member_id); Den xriazete giati pernete apo tin basi oxi apo xristi
	
	$query = "SELECT  `member_id` FROM `rate` WHERE  game_id='$game_id' AND member_id='$member_id'";
	$result=exec_sql_query($query);
	
	$num_rows = mysql_num_rows($result);
	if ($num_rows > 0)
		update_rate($game_id, $member_id, $rate);
	else 
	{
		insert_rate($game_id, $member_id, $rate);
		//return true;   Afto gt to evales edo?
	}
	get_avg_rate($game_id);
}
//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------

//------------------------------------------------------------------------------------------------
?>